private boolean isValidEmail(String email){
   String regexPattern="^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+$";
   return Pattern.matches(regexPattern, email); 
}

// 使用前先做校验
if (!isValidEmail(userInput)){
     throw new IllegalArgumentException("无效邮箱地址！");
} else{
     processUserEmail(userInput);
}